import 'package:permission_handler/permission_handler.dart';

/// ### 获取读写权限
Future<bool> checkPermission() async {
  // 检查是否已有读写内存权限
  PermissionStatus status = await PermissionHandler().checkPermissionStatus(PermissionGroup.storage);

  // 判断如果还没拥有读写权限就申请获取权限
  if(status != PermissionStatus.granted){
    var map = await PermissionHandler().requestPermissions([PermissionGroup.storage]);
    if(map[PermissionGroup.storage] != PermissionStatus.granted) return false;
  }

  // 返回状态
  return true;
}



